#ifndef __NETCORE_H__
#define __NETCORE_H__

#ifdef __cplusplus
extern "C"
{
#endif

#include <types.h>
#include <device.h>

struct sockaddr_in;

int net_ip4_addr(const ip_addr_t *ip, u16 port, struct sockaddr_in *addr);
void net_addr_from_sockaddr(const struct sockaddr_in *addr, ip_addr_t *ip, u16 *port);
int net_socket_bind(device_t *dev, const ip_addr_t *ip, u16 port);
int net_socket_bind_to_path(device_t *dev, const char *name);
int net_conn(device_t *dev, const ip_addr_t *ip, u16 port);
int net_conn_to_path(device_t *dev, const char *name);
int net_accept(int sock, ip_addr_t *ip, u16 *port);
int net_tcp_nodelay(int sock, int on);
int net_nonblock(int sock, int set);
int net_cloexec_ioctl(int sock, int set);
int net_bindto_eth(int sock, const char *ethname);

int socket_new(device_t *dev, const char *ethname, int type, const ip_addr_t *ip, u16 port);
int socket_new_local(device_t *dev, int type, const char *name);
void socket_del(int sock);

u16 get_local_port_rand(int type);
int net_get_if_status(const char *ifname);
int net_get_if_ip(const char *ifname, ip_addr_t *ip);
int net_get_sock_ip(int sock, const char *ifname, ip_addr_t *ip);
int net_get_if_mac(const char *ifname, char *mac);
int net_set_if_mac(const char *ifname, char *mac);
#ifdef __cplusplus
}
#endif
#endif

